import 'dart:convert';

import '../generated/json/base/json_field.dart';
import '../generated/json/reader_entity.g.dart';

@JsonSerializable()
class ReaderEntity {

	@JSONField(name: "valid_reader")
	bool? validReader;
	@JSONField(name: "valid_password")
	bool? validPassword;
	String? no;
	String? name;
	@JSONField(name: "icr_no")
	dynamic icrNo;
	@JSONField(name: "state_value")
	String? stateValue;
	@JSONField(name: "limit_count")
	int? limitCount;
	@JSONField(name: "limit_days")
	int? limitDays;
	String? org;
	@JSONField(name: "current_borrow_count")
	int? currentBorrowCount;
	@JSONField(name: "current_borrow_list")
	List<ReaderCurrentBorrowList>? currentBorrowList;
  
  ReaderEntity();

  factory ReaderEntity.fromJson(Map<String, dynamic> json) => $ReaderEntityFromJson(json);

  Map<String, dynamic> toJson() => $ReaderEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class ReaderCurrentBorrowList {

	@JSONField(name: "book_no")
	String? bookNo;
	@JSONField(name: "book_title")
	String? bookTitle;
	@JSONField(name: "ready_return_date")
	String? readyReturnDate;
	bool? overdue;

	//0 = 未续借
	//1 = 续借失败
	//2 = 续借成功
	int? status = 0;

	String? error;

  ReaderCurrentBorrowList();

  factory ReaderCurrentBorrowList.fromJson(Map<String, dynamic> json) => $ReaderCurrentBorrowListFromJson(json);

  Map<String, dynamic> toJson() => $ReaderCurrentBorrowListToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}